#include "../inc.h"

class Drawable : public IDrawable {
 protected:
  struct nk_colorf bkcolor_;
 public:
  virtual const char* title() override { return "Nuklear Demo"; }
  virtual struct nk_colorf bkcolor() override { return bkcolor_; }
  virtual void init() override { bkcolor_ = IDrawable::bkcolor(); };
  virtual void uninit() override {};
  virtual void update(float elapsedTime) override {};
  virtual void render() override {};
  virtual void imgui(nk_context *ctx, struct nk_rect &rc) override {
    /* GUI */
    if (nk_begin(ctx, "Demo", nk_rect(50, 50, 230, 250),
        NK_WINDOW_BORDER|NK_WINDOW_MOVABLE|NK_WINDOW_SCALABLE|
        NK_WINDOW_MINIMIZABLE|NK_WINDOW_TITLE)) {
      enum {EASY, HARD};
      static int op = EASY;
      static int property = 20;

      nk_layout_row_static(ctx, 30, 80, 1);
      if (nk_button_label(ctx, "button"))
          printf("button pressed!\n");
      nk_layout_row_dynamic(ctx, 30, 2);
      if (nk_option_label(ctx, "easy", op == EASY)) op = EASY;
      if (nk_option_label(ctx, "hard", op == HARD)) op = HARD;
      nk_layout_row_dynamic(ctx, 22, 1);
      nk_property_int(ctx, "Compression:", 0, &property, 100, 10, 1);

      nk_layout_row_dynamic(ctx, 20, 1);
      nk_label(ctx, "background:", NK_TEXT_LEFT);
      nk_layout_row_dynamic(ctx, 25, 1);
      if (nk_combo_begin_color(ctx, nk_rgb_cf(bkcolor_), nk_vec2(nk_widget_width(ctx),400))) {
        nk_layout_row_dynamic(ctx, 120, 1);
        bkcolor_ = nk_color_picker(ctx, bkcolor_, NK_RGBA);
        nk_layout_row_dynamic(ctx, 25, 1);
        bkcolor_.r = nk_propertyf(ctx, "#R:", 0, bkcolor_.r, 1.0f, 0.01f,0.005f);
        bkcolor_.g = nk_propertyf(ctx, "#G:", 0, bkcolor_.g, 1.0f, 0.01f,0.005f);
        bkcolor_.b = nk_propertyf(ctx, "#B:", 0, bkcolor_.b, 1.0f, 0.01f,0.005f);
        bkcolor_.a = nk_propertyf(ctx, "#A:", 0, bkcolor_.a, 1.0f, 0.01f,0.005f);
        nk_combo_end(ctx);
      }
    }
    nk_end(ctx);
  };
  virtual void processInput(sdl::event::Event &evt) override {};
};

IDrawable* createDrawable() {
  return new Drawable();
}